#!/bin/bash
budo service docker start
# sudo service docker restart
port=9999
echo  'jenkins will run at server port :' $port

if  [ -n "$1" ] ;then
   echo '$1' $1 $2
   port=$2
   echo 'jenkins  port changed to' $2
fi

echo 'port => '$port
docker rm -f jenkins$port
mkdir /var/jenkins_home  -p
chown -R 1000 /var/jenkins_home
systemctl restart docker
sudo docker run  -itd --restart=always  -p $port:8080 -p 50000:50000  --dns 8.8.8.8 --dns 8.8.4.4 --name  jenkins$port \
-v /var/run/docker.sock:/var/run/docker.sock \
  -v /usr/java/jdk1.8.0_151/bin/java:/usr/java/jdk1.8.0_151/bin/java \
  -v /usr/java/jdk1.8.0_151:/usr/java/jdk1.8.0_151 \
  -v /usr/share/maven:/usr/local/maven \
  -v /var/jenkins_home:/var/jenkins_home \
  jenkinsci/blueocean
